package com.wondertek.poms.dao.po;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.wondertek.poms.common.constant.CurrentUser;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.Proxy;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 * <p><b>PcImageTransRules Description:</b> PcImageTransRules po类 ; 转图规则表 </p>
 *
 * @author 窦再兴
 * <p><b>DATE</b> 2020-10-19 09:35:09</p>
 */
@Data
@Entity
@Table(name = "pc_image_trans_rules")
@DynamicUpdate
@DynamicInsert
@Proxy(lazy = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class PcImageTransRules implements java.io.Serializable {

	/**
	 * <b>Fields</b> serialVersionUID :
	 */
	private static final long serialVersionUID = -723644421148044740L;

	/**
	 * <b>Fields</b> id : 主键ID
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "PC_IMAGE_TRANS_RULES_SEQ")
	@SequenceGenerator(name = "PC_IMAGE_TRANS_RULES_SEQ", allocationSize = 1, sequenceName = "PC_IMAGE_TRANS_RULES_SEQ")
	private Long id;

	/**
	 * <b>Fields</b> imageSrcId : 原图id
	 */
	@Column(name = "image_src_id")
	private Long imageSrcId;

	/**
	 * <b>Fields</b> transRuleName : 转图后规则名称
	 */
	@Column(name = "trans_rule_name")
	private String transRuleName;

	/**
	 * <b>Fields</b> platform : 所属平台 1:小屏2:大屏3:VR 4:所有平台
	 */
	@Column(name = "PLATFORM")
	private String platform;

	/**
	 * <b>Fields</b> width : 目标图宽度
	 */
	@Column(name = "WIDTH")
	private Integer width;

	/**
	 * <b>Fields</b> height : 目标图高度
	 */
	@Column(name = "HEIGHT")
	private Integer height;

	/**
	 * <b>Fields</b> type : 目标图类型 1: .jpg 2: .webp
	 */
	@Column(name = "TYPE")
	private String type;

	/**
	 * <b>Fields</b> createdBy : 创建人
	 */
	@Column(name = "created_by")
	private String createdBy;

	/**
	 * <b>Fields</b> createdTime : 创建时间
	 */
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@Column(name = "created_time")
	private java.time.LocalDateTime createdTime;

	/**
	 * <b>Fields</b> updatedBy : 更新人
	 */
	@Column(name = "updated_by")
	private String updatedBy;

	/**
	 * <b>Fields</b> updatedTime : 更新时间
	 */
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@Column(name = "updated_time")
	private java.time.LocalDateTime updatedTime;

	/**
	 * <b>Fields</b> deleted : 是否有效 0正常 1删除 2停用
	 */
	@Column(name = "DELETED")
	private Integer deleted = 0;

	public static void putTimeAndUser(PcImageTransRules pcImageTransRules) {
		if (pcImageTransRules.id == null) {
			pcImageTransRules.setCreatedBy(CurrentUser.currUserName());
			pcImageTransRules.setCreatedTime(java.time.LocalDateTime.now());
		}
		pcImageTransRules.setUpdatedBy(CurrentUser.currUserName());
		pcImageTransRules.setUpdatedTime(java.time.LocalDateTime.now());
	}
}